'use strict';

angular.module('myApp.competition_new', [])

.controller('competition_newCtrl', ['$scope','$http', 
    function($scope,$http,$location) {
	$http.get('v1/competition').success(function(data){
		$scope.competitions= data.result['data'];
        console.log(data);
	});

    $scope.open = function(competition){
    	competition.is_published = 1;
        $scope.tem = competition.is_published;
        $scope.temid = competition.id;
    	var change = {'is_published' : 1};        
        $http.put('v1/competition/'+ $scope.temid,change).success(function(data){
            if( !data.error ){
                alert("修改成功","success");
            }else{
                alert(data.message);
            }
        });
    };

}]);